package com.gitee.wsl.security.encrypt

import com.gitee.wsl.func.InvokeCall


interface Encrypt<T,V> : InvokeCall<T, V> {

    fun encrypt(src:T):V

    fun decrypt(src:V):T

    override fun invoke(t: T) = encrypt(t)

    companion object

}

interface StringEncrypt<V>: Encrypt<String, V>{

    companion object
}


typealias StringToStringEncrypt = StringEncrypt<String>


typealias StringToByteArrayEncrypt = StringEncrypt<ByteArray>

fun <T> String.encrypt(type: StringEncrypt<T>) = type.encrypt(this)

fun String.decrypt(type: StringToStringEncrypt) = type.decrypt(this)

fun ByteArray.decrypt(type: StringToByteArrayEncrypt) = type.decrypt(this)